﻿using System.Net.Mail;
using System.Text;

namespace Engine
{
    public sealed class SmtpEmailSender : IEmailSender
    {
        private readonly string m_Host;

        public SmtpEmailSender(string host)
        {
            m_Host = host;
        }

        public void Send(string from, string to, string subject, string body)
        {
            using (MailMessage mm = new MailMessage())
            {
                SmtpClient smtpClient = new SmtpClient(m_Host);
                mm.From = new MailAddress(from);
                mm.Subject = subject;
                mm.Body = body;
                mm.To.Add(to);
                mm.BodyEncoding = Encoding.UTF8;
                smtpClient.Send(mm);
            }
        }
    }
}